import { ServerResponse } from '@/util/base/ServerResponse'
import { Request } from '@/util/http/axios'
import LoginForm from '../params/login'
import { LoginVo } from '../vo/loginVo'

export default class LoginServiceApi {
  // 获取验证码
  async captcha () :Promise<string> {
    const res = await Request.get<string, void>(
      '/captcha')
    console.log(res.data)
    return res.data
  }

  // 登录
  // 返回的data类型为LoginVo类型
  async login (loginForm: LoginForm): Promise<ServerResponse<LoginVo>> {
    const res = await Request.post<ServerResponse<LoginVo>, LoginForm>(
      '/login',
      loginForm)
    // res.data才是真正的返回的内容
    return res.data
  }
}
